<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
function Calc(a, b) {
    this.a = a;
    this.b = b;

    this.add = function() {
        return this.a + this.b;
    }

    this.sub = function() {
        return this.a - this.b;
    }

    this.mul = function() {
        return this.a * this.b;
    }

    this.div = function() {
        if (this.b === 0) {
            console.log('Error: Division by zero is not allowed!');
            return null;
        }
        return this.a / this.b;
    }
}

// 使用方法
let calc = new Calc(32, 43);
let r1 = calc.add();        // 输出 75
let r2 = calc.sub();   // 输出 -11
let r3 = calc.mul();   // 输出 1376
let r4 = calc.div();     // 输出 0.7441860465116279
console.log(r1,r2,r3,r4);
</script>

</body>
</html>